<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->title;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/load.js"></script>
<!--时间选择器-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/lang/cn_utf8.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-setup.js"></script>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/js/date/calendar-blue.css" />
<!--colorbox-->
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/jquery.colorbox.js"></script>
<link href="<?php echo $this->baseUrl;?>/files/admin/js/colorbox.jquery/colorbox2.css" rel="stylesheet" type="text/css"/>
<style>
#content{ min-height:600px;_height:600px;}


.table td{ text-align:right;}
.table .textLeft{ text-align:left;}
.table .count td{ text-align:right;}
.table .count .textCenter { text-align: center;}
.table .member-data-body .textLeft{ text-align:left;}
</style>
<script language="javascript">
function selData(action,dateType,doType){
    $('#searchForm').attr('action', action);
	$('#dateType').attr('value', dateType);
	$('#doType').attr('value', doType);
    $('#searchForm').submit();
}

function low(val,name,startTime,endTime,strCode){
	if($('input#inpu_'+val).val() == '1'){
		$('span#sons_'+val).html('加载中...');
		$.ajax({ 
			 url: "<?php echo $this->projectUrl(array('controller'=>'activation-analytics','action'=>'get-source-name-list'));?>",
			 type:"post",           
			 dataType:"json",
			 data: "name="+name+"&startTime="+startTime+"&endTime="+endTime+"&strCode="+strCode,
			 success:function(data){ 
				$('table#son_'+val).html(data.table);
				$('input#inpu_'+val).val('2');
				$('span#sons_'+val).hide()
			 } 
		});
	}
	$check = $('span#img_'+val).text();
	if($check == '+'){
		$('#son_'+val).css('display','block');
		$('span#img_'+val).html('-');
	}else{
		$('#son_'+val).css('display','none');
		$('span#img_'+val).html('+');
	}
}

function selData(action,dateType,doType){
    $('#searchForm').attr('action', action);
	$('#dateType').attr('value', dateType);
	$('#doType').attr('value', doType);
    $('#searchForm').submit();
}
</script>
</head>

<body style="overflow:auto;">
	<div id="main">
		<div id="topMenu">
			<div id="navigation">当前位置：激活量分析</div>
			<div id="topOtherMenu"></div>
		</div>
		<div id="body">
			<div id="search">
				<form id="searchForm" name="searchForm" method="post" action="<?php echo $this->projectUrl(array('action'=>'list'));?>">
					<!-- 时间选择条 -->
					<div id="timeRange">
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',6,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==6 ? 'currentTimeRange' : ''?>">今天</a>
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',1,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==1 ? 'currentTimeRange' : ''?>">昨天</a> 
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',2,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==2 ? 'currentTimeRange' : ''?>">最近7天</a> 
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',3,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==3 ? 'currentTimeRange' : ''?>">最近30天</a> 
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',4,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==4 ? 'currentTimeRange' : ''?>">最近三个月</a> 
					<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',5,<?php echo $this->vars['doType'];?>);" class="<?php echo $this->vars['dateType']==5 ? 'currentTimeRange' : ''?>">全部</a>&nbsp;&nbsp;&nbsp;&nbsp;
						<span>日期选择</span>：<input name="startTime" type="text" class="input" id="startTime" size="18" value="<?php echo $this->vars['startTime'];?>" /><script type="text/javascript">Calendar.setup({"ifFormat":"%Y-%m-%d","firstDay":0,"showsTime":true,"showOthers":false,"timeFormat":24,"inputField":"startTime","button":"startTime"});</script>
		-
		<input name="endTime" type="text" class="input" id="endTime" size="18" value="<?php echo $this->vars['endTime'];?>" />
		<script type="text/javascript">Calendar.setup({"ifFormat":"%Y-%m-%d","firstDay":0,"showsTime":true,"showOthers":false,"timeFormat":24,"inputField":"endTime","button":"endTime"});</script>
	
						<input type="hidden" name="dateType" id="dateType" value="<?php echo $this->vars['dateType'];?>" />
						<input type="hidden" name="doType" id="doType" value="<?php echo $this->vars['doType'];?>" />
						<input name="search" type="button" id="search" value="查找" class="button" onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',7,<?php echo $this->vars['doType'];?>);"/>							
					</div>
					<!-- 时间选择条 -->			
			  </form>
			</div>
			<div id="content">
				<div class="d-title">
				<a style="cursor:pointer" onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',<?php echo $this->vars['dateType'];?>,1);" class="<?php echo $this->vars['doType']==1 ? 'on' : ''?>">渠道</a>
				<a style="cursor:pointer" onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',<?php echo $this->vars['dateType'];?>,3);" class="<?php echo $this->vars['doType']==3 ? 'on' : ''?>">操作系统</a> 
				<a style="cursor:pointer" onclick="selData('<?php echo $this->projectUrl(array('action'=>'list')) ;?>',<?php echo $this->vars['dateType'];?>,4);" class="<?php echo $this->vars['doType']==4 ? 'on' : ''?>">地域</a>
				<a onclick="selData('<?php echo $this->projectUrl(array('action'=>'list','export'=>'yes')) ;?>',<?php echo $this->vars['dateType'];?>,'<?php echo $this->vars['doType'];?>');" style="cursor:pointer; background:none; padding-left:40px; text-decoration:none;">[输出Excel文件]</a>
				<div  style="clear:both;"></div>
				</div>
				<form id="listForm" name="listForm" method="post" action="">
					<table class="table reportTable">
						<tr class="subject">
						  <td><?php if($this->vars['doType']=='3'){echo '操作系统';}elseif($this->vars['doType']=='4'){echo '地域';}else{echo '渠道';}?></td>
						  <td colspan="2">激活</td>
						  <td colspan="3">激活带来的订单</td>
					  </tr>
						<tr class="subject">
							<td>名称</td>
							<td>数量</td>
							<td>占比(%)</td>
							<td>订单量</td>
							<td>占比(%)</td>
							<td>订单金额(￥)</td>
						</tr>
						<?php 
							$i=1;
							foreach($this->tmpArray as $item):
						?>
						<tr class="dataLine  <?php echo ($i%2 == 0) ? 'data-show-2' : 'data-show-1';?>" id="parent_<?php echo $item['code']?>">
						  <td class="textLeft">
						  <?php if($this->vars['doType']==1):?>
							  <?php if($item['name'] == '其他'):?>
							  <span style="cursor:pointer" id="img_<?php echo $item['code']?>" onclick="low('<?php echo $item['code']?>','<?php echo $item['name']?>','<?php echo $this->vars['startTime'];?>','<?php echo $this->vars['endTime'];?>','<?php echo $item['strCode']?>');">+</span>
							  <?php else:?>
							  <span style="cursor:pointer" id="img_<?php echo $item['code']?>" onclick="low('<?php echo $item['code']?>','<?php echo $item['name']?>','<?php echo $this->vars['startTime'];?>','<?php echo $this->vars['endTime'];?>','');">+</span>
							  <?php endif;?>
						  <?php endif;?>
						  <?php echo $item['name'];?>
						  </td>
						  <td><?php echo $item['installNum'];?></td>
						  <td><?php echo $item['installNumPer'].'%';?></td>
						  <td><?php echo $item['installOkOrderNum'];?></td>
						  <td><?php echo $item['installOkOrderNumPer'].'%';?></td>
						  <td><?php echo $item['amount'];?></td>
					  	</tr>
						
						<input id="inpu_<?php echo $item['code'];?>" value="1" type="hidden" />
						<tr>
						  <td colspan="6"  style="padding:0 5px; text-align:left;">
						  	<span id="sons_<?php echo $item['code'];?>"></span>
							<table width="100%" border="0" cellpadding="0" id="son_<?php echo $item['code'];?>" cellspacing="0" class="member-data-body  member-data-1" style="display:none; text-align:left;margin:5px 0;">
							</table>

						  </td>
					    </tr>
						
						
						<?php 
							$i++;
							endforeach;
							if(empty($this->tmpArray)):
						?>
						<tr class="dataLine">
						  <td colspan="6">
						  没有找到相关记录！						  </td>
					  	</tr>
						<?php
							endif;
							if(!empty($this->tmpArray)):
						?>
						<tr class="subject count">
							<td class="textCenter">总计</td>
							<td><?php echo $this->totalArray['installNumTotal'];?></td>
							<td><?php echo $this->totalArray['installNumTotalPer'];?></td>
							<td><?php echo $this->totalArray['installOkOrderNumTotal'];?></td>
							<td><?php echo $this->totalArray['installOkOrderNumTotalPer'];?></td>
							<td><?php echo $this->totalArray['amountTotal'];?></td>
						</tr>
						<?php endif;?>
				  </table>
				</form>
				<div  class="d-note" style="color:red">
				激活带来的订单并不含有老用户产生的订单
				<?php if($this->type=='4'):?>
				未知：未知来源IP产生的订单
				<?php endif;?>
				</div>
		</div>
		</div>
	</div>
</body>
</html>